home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BounceBack.dxr / 00005_Brick Behavior.ls < prev    next >
Encoding:
Text File  |  2002-01-31  |  17.4 KB  |  474 lines

  1. property spriteNum, pBricksLeft, pKount, pTemper, pTempDirection
  2. global gSlowDown, gBallDirection, gLevel, gScore, gLocH, gLocV, gBallSpeed, gPaddleHits, gPause, gFallingBricks, gFallSprite, gDescend, h, v, pMyAngle, gGoBall
  3.  
  4. on beginSprite
  5.   repeat with pBricksLeft = 20 to 79
  6.     sprite(pBricksLeft).visible = 1
  7.   end repeat
  8.   pSlowDown = 0
  9.   pKount = 0
  10.   gFallingBricks = [0, 0, 0, 0]
  11.   gDescend = [0, 0, 0, 0]
  12.   gFallSprite = [0, 0, 0, 0]
  13. end
  14.  
  15. on exitFrame me
  16.   donutAttack(me)
  17.   if gPause = 0 then
  18.     if (sprite(4).locH > (sprite(spriteNum).locH - 50)) and (sprite(4).locH < (sprite(spriteNum).locH + 50)) and (sprite(4).locV < (sprite(spriteNum).locV + 25)) and (sprite(4).locV > (sprite(spriteNum).locV - 25)) then
  19.       if sprite(4).intersects(spriteNum) then
  20.         if (sprite(spriteNum).member.name = "Brick_crome") or (sprite(spriteNum).member.name = "Brick02_animated") or (sprite(spriteNum).member.name = "GooBrickShort") or (sprite(spriteNum).member.name = "Brick_Metal02") or (sprite(spriteNum).member.name = "Brick01_animated") then
  21.           puppetSound(1, "brick")
  22.           gLocH = gLocH - h
  23.           gLocV = gLocV - v
  24.           updateStage()
  25.           repeat with pTemper = 1 to 17
  26.             pTempDirection = getAngle(sprite(4).locH, sprite(4).locV, sprite(5).locH, sprite(5).locV)
  27.             pMyAngle = pTempDirection * PI / 180.0
  28.             h = sin(pMyAngle) * 1
  29.             v = -cos(pMyAngle) * 1
  30.             gLocH = gLocH + h
  31.             gLocV = gLocV + v
  32.             sprite(5).loc = point(gLocH, gLocV)
  33.             if sprite(5).intersects(spriteNum) then
  34.               pBottomDist = abs(sprite(5).rect.top - sprite(spriteNum).rect.bottom)
  35.               pTopDist = abs(sprite(spriteNum).rect.top - sprite(5).rect.bottom)
  36.               pRightDist = abs(sprite(5).rect.left - sprite(spriteNum).rect.right)
  37.               pLeftDist = abs(sprite(spriteNum).rect.left - sprite(5).rect.right)
  38.               if (pBottomDist < pTopDist) and (pBottomDist < pLeftDist) and (pBottomDist < pRightDist) then
  39.                 BottomCollision()
  40.               else
  41.                 if (pTopDist < pBottomDist) and (pTopDist < pLeftDist) and (pTopDist < pRightDist) then
  42.                   TopCollision()
  43.                 else
  44.                   if (pRightDist < pBottomDist) and (pRightDist < pLeftDist) and (pRightDist < pTopDist) then
  45.                     gBallDirection = 270 - gBallDirection + 90 + (random(4) - 2)
  46.                     LeftAndRightCollision()
  47.                   else
  48.                     if (pLeftDist < pBottomDist) and (pLeftDist < pRightDist) and (pLeftDist < pTopDist) then
  49.                       gBallDirection = 90 - gBallDirection + 270 + (random(4) - 2)
  50.                       LeftAndRightCollision()
  51.                     end if
  52.                   end if
  53.                 end if
  54.               end if
  55.               sprite(4).loc = sprite(5).loc
  56.               exit repeat
  57.             end if
  58.           end repeat
  59.           if gLevel = 1 then
  60.             pKount = 0
  61.             repeat with pBricksLeft = 20 to 79
  62.               if sprite(pBricksLeft).visible = 0 then
  63.                 pKount = pKount + 1
  64.               end if
  65.               if pKount >= 32 then
  66.                 repeat with pBricksLeft = 20 to 79
  67.                   sprite(pBricksLeft).visible = 1
  68.                 end repeat
  69.                 sprite(80).visible = 0
  70.                 sprite(12).visible = 1
  71.                 sprite(12).locV = 220
  72.                 gPause = 1
  73.                 gBallSpeed = 4
  74.                 gPaddleHits = 0
  75.                 gBallDirection = 180.0
  76.                 gLocH = 290
  77.                 gLocV = 270
  78.                 member("Level1Score").text = "Level 1 Score:" && string(gScore)
  79.                 member("Level1Score_b").text = "Level 1 Score:" && string(gScore)
  80.                 go(16)
  81.               end if
  82.             end repeat
  83.             pKount = 0
  84.           else
  85.             if gLevel = 2 then
  86.               pKount = 0
  87.               repeat with pBricksLeft = 20 to 79
  88.                 if sprite(pBricksLeft).visible = 0 then
  89.                   pKount = pKount + 1
  90.                 end if
  91.                 if pKount >= 50 then
  92.                   repeat with pBricksLeft = 20 to 79
  93.                     sprite(pBricksLeft).visible = 1
  94.                   end repeat
  95.                   sprite(80).visible = 0
  96.                   sprite(12).visible = 1
  97.                   sprite(12).locV = 220
  98.                   gPause = 1
  99.                   gBallSpeed = 4
  100.                   gPaddleHits = 0
  101.                   gBallDirection = 180.0
  102.                   gLocH = 290
  103.                   gLocV = 270
  104.                   member("Level2_score").text = "Level 2 Score:" && string(gScore)
  105.                   member("Level2_score_b").text = "Level 2 Score:" && string(gScore)
  106.                   go(29)
  107.                 end if
  108.               end repeat
  109.               pKount = 0
  110.             else
  111.               if gLevel = 3 then
  112.                 pKount = 0
  113.                 repeat with pBricksLeft = 20 to 79
  114.                   if sprite(pBricksLeft).visible = 0 then
  115.                     pKount = pKount + 1
  116.                   end if
  117.                   if pKount >= 50 then
  118.                     repeat with pBricksLeft = 20 to 79
  119.                       sprite(pBricksLeft).visible = 1
  120.                     end repeat
  121.                     sprite(80).visible = 0
  122.                     sprite(12).visible = 1
  123.                     sprite(12).locV = 220
  124.                     gPause = 1
  125.                     gBallSpeed = 4
  126.                     gPaddleHits = 0
  127.                     gBallDirection = 180.0
  128.                     gLocH = 290
  129.                     gLocV = 270
  130.                     member("Level3Score").text = "Level 3 Score:" && string(gScore)
  131.                     member("Level3Score_b").text = "Level 3 Score:" && string(gScore)
  132.                     go(41)
  133.                   end if
  134.                 end repeat
  135.                 pKount = 0
  136.               else
  137.                 if gLevel = 4 then
  138.                   pKount = 0
  139.                   repeat with pBricksLeft = 20 to 79
  140.                     if sprite(pBricksLeft).visible = 0 then
  141.                       pKount = pKount + 1
  142.                     end if
  143.                     if pKount >= 26 then
  144.                       repeat with pBricksLeft = 20 to 79
  145.                         sprite(pBricksLeft).visible = 1
  146.                       end repeat
  147.                       sprite(80).visible = 0
  148.                       sprite(12).visible = 1
  149.                       sprite(12).locV = 220
  150.                       gPause = 1
  151.                       gBallSpeed = 4
  152.                       gPaddleHits = 0
  153.                       gBallDirection = 180.0
  154.                       gLocH = 290
  155.                       gLocV = 270
  156.                       member("Leve4Score").text = "Level 4 Score:" && string(gScore)
  157.                       member("Leve4Score_b").text = "Level 4 Score:" && string(gScore)
  158.                       go(54)
  159.                     end if
  160.                   end repeat
  161.                   pKount = 0
  162.                 else
  163.                   if gLevel = 5 then
  164.                     pKount = 0
  165.                     repeat with pBricksLeft = 20 to 79
  166.                       if sprite(pBricksLeft).visible = 0 then
  167.                         pKount = pKount + 1
  168.                       end if
  169.                       if pKount >= 22 then
  170.                         repeat with pBricksLeft = 20 to 79
  171.                           sprite(pBricksLeft).visible = 1
  172.                         end repeat
  173.                         sprite(80).visible = 0
  174.                         sprite(12).visible = 1
  175.                         sprite(12).locV = 220
  176.                         gPause = 1
  177.                         gBallSpeed = 4
  178.                         gPaddleHits = 0
  179.                         gBallDirection = 180.0
  180.                         gLocH = 290
  181.                         gLocV = 270
  182.                         member("FinalScore").text = "Final Score:" && string(gScore)
  183.                         member("FinalScore_b").text = "Final Score:" && string(gScore)
  184.                         go(69)
  185.                       end if
  186.                     end repeat
  187.                     pKount = 0
  188.                   end if
  189.                 end if
  190.               end if
  191.             end if
  192.           end if
  193.         end if
  194.         if gBallDirection > 360 then
  195.           gBallDirection = gBallDirection - 360
  196.         else
  197.           if gBallDirection < 0 then
  198.             gBallDirection = gBallDirection + 360
  199.           end if
  200.         end if
  201.       end if
  202.     end if
  203.   end if
  204. end
  205.  
  206. on TopCollision
  207.   if sprite(spriteNum).member.name = "Brick_crome" then
  208.     gBallDirection = 0 - gBallDirection + 180 + (random(4) - 2)
  209.     sprite(spriteNum).visible = 0
  210.     sprite(spriteNum).member = 0
  211.     gScore = gScore + 100
  212.     member("Score01").text = "Score:" && string(gScore)
  213.     member("Score02").text = "Score:" && string(gScore)
  214.   else
  215.     if sprite(spriteNum).member.name = "Brick01_animated" then
  216.       gBallDirection = 0 - gBallDirection + 180 + (random(4) - 2)
  217.       sprite(spriteNum).member = "Brick_crome"
  218.       gScore = gScore + 100
  219.       member("Score01").text = "Score:" && string(gScore)
  220.       member("Score02").text = "Score:" && string(gScore)
  221.     else
  222.       if sprite(spriteNum).member.name = "Brick02_animated" then
  223.         gBallDirection = 290 + random(140)
  224.         sprite(spriteNum).member = "Brick_crome"
  225.         gScore = gScore + 100
  226.         member("Score01").text = "Score:" && string(gScore)
  227.         member("Score02").text = "Score:" && string(gScore)
  228.       else
  229.         if sprite(spriteNum).member.name = "GooBrickShort" then
  230.           sprite(spriteNum).member = "GooDrop_Ani_12f"
  231.           gBallDirection = 0 - gBallDirection + 180 + (random(4) - 2)
  232.           if gFallingBricks[1] = 0 then
  233.             puppetSound(3, "blue circle drop")
  234.             gFallSprite[1] = spriteNum
  235.             gFallingBricks[1] = 1
  236.           else
  237.             if gFallingBricks[2] = 0 then
  238.               puppetSound(3, "blue circle drop")
  239.               gFallSprite[2] = spriteNum
  240.               gFallingBricks[2] = 1
  241.             else
  242.               if gFallingBricks[3] = 0 then
  243.                 puppetSound(3, "blue circle drop")
  244.                 gFallSprite[3] = spriteNum
  245.                 gFallingBricks[3] = 1
  246.               else
  247.                 if gFallingBricks[4] = 0 then
  248.                   puppetSound(3, "blue circle drop")
  249.                   gFallSprite[4] = spriteNum
  250.                   gFallingBricks[4] = 1
  251.                 end if
  252.               end if
  253.             end if
  254.           end if
  255.           gScore = gScore + 300
  256.           member("Score01").text = "Score:" && string(gScore)
  257.           member("Score02").text = "Score:" && string(gScore)
  258.         else
  259.           if sprite(spriteNum).member.name = "Brick_Metal02" then
  260.             gBallDirection = 180 - gBallDirection + 360 + (random(4) - 2)
  261.           end if
  262.         end if
  263.       end if
  264.     end if
  265.   end if
  266. end
  267.  
  268. on BottomCollision
  269.   if sprite(spriteNum).member.name = "Brick_crome" then
  270.     gBallDirection = 180 - gBallDirection + 360 + (random(4) - 2)
  271.     sprite(spriteNum).visible = 0
  272.     sprite(spriteNum).member = 0
  273.     gScore = gScore + 100
  274.     member("Score01").text = "Score:" && string(gScore)
  275.     member("Score02").text = "Score:" && string(gScore)
  276.   else
  277.     if sprite(spriteNum).member.name = "Brick01_animated" then
  278.       gBallDirection = 180 + (random(8) - 4)
  279.       sprite(spriteNum).member = "Brick_crome"
  280.       gScore = gScore + 100
  281.       member("Score01").text = "Score:" && string(gScore)
  282.       member("Score02").text = "Score:" && string(gScore)
  283.     else
  284.       if sprite(spriteNum).member.name = "Brick02_animated" then
  285.         gBallDirection = 110 + random(140)
  286.         sprite(spriteNum).member = "Brick_crome"
  287.         gScore = gScore + 100
  288.         member("Score01").text = "Score:" && string(gScore)
  289.         member("Score02").text = "Score:" && string(gScore)
  290.       else
  291.         if sprite(spriteNum).member.name = "GooBrickShort" then
  292.           sprite(spriteNum).member = "GooDrop_Ani_12f"
  293.           gBallDirection = 180 - gBallDirection + 360 + (random(4) - 2)
  294.           if gFallingBricks[1] = 0 then
  295.             puppetSound(3, "blue circle drop")
  296.             gFallSprite[1] = spriteNum
  297.             gFallingBricks[1] = 1
  298.           else
  299.             if gFallingBricks[2] = 0 then
  300.               puppetSound(3, "blue circle drop")
  301.               gFallSprite[2] = spriteNum
  302.               gFallingBricks[2] = 1
  303.             else
  304.               if gFallingBricks[3] = 0 then
  305.                 puppetSound(3, "blue circle drop")
  306.                 gFallSprite[3] = spriteNum
  307.                 gFallingBricks[3] = 1
  308.               else
  309.                 if gFallingBricks[4] = 0 then
  310.                   puppetSound(3, "blue circle drop")
  311.                   gFallSprite[4] = spriteNum
  312.                   gFallingBricks[4] = 1
  313.                 end if
  314.               end if
  315.             end if
  316.           end if
  317.           gScore = gScore + 300
  318.           member("Score01").text = "Score:" && string(gScore)
  319.           member("Score02").text = "Score:" && string(gScore)
  320.         else
  321.           if sprite(spriteNum).member.name = "Brick_Metal02" then
  322.             gBallDirection = 180 - gBallDirection + 360 + (random(4) - 2)
  323.           end if
  324.         end if
  325.       end if
  326.     end if
  327.   end if
  328. end
  329.  
  330. on LeftAndRightCollision
  331.   if sprite(spriteNum).member.name = "Brick_crome" then
  332.     sprite(spriteNum).visible = 0
  333.     sprite(spriteNum).member = 0
  334.     gScore = gScore + 100
  335.     member("Score01").text = "Score:" && string(gScore)
  336.     member("Score02").text = "Score:" && string(gScore)
  337.   else
  338.     if sprite(spriteNum).member.name = "Brick01_animated" then
  339.       sprite(spriteNum).member = "Brick_crome"
  340.       gScore = gScore + 100
  341.       member("Score01").text = "Score:" && string(gScore)
  342.       member("Score02").text = "Score:" && string(gScore)
  343.     else
  344.       if sprite(spriteNum).member.name = "Brick02_animated" then
  345.         sprite(spriteNum).member = "Brick_crome"
  346.         gScore = gScore + 100
  347.         member("Score01").text = "Score:" && string(gScore)
  348.         member("Score02").text = "Score:" && string(gScore)
  349.       else
  350.         if sprite(spriteNum).member.name = "GooBrickShort" then
  351.           sprite(spriteNum).member = "GooDrop_Ani_12f"
  352.           if gFallingBricks[1] = 0 then
  353.             puppetSound(3, "blue circle drop")
  354.             gFallSprite[1] = spriteNum
  355.             gFallingBricks[1] = 1
  356.           else
  357.             if gFallingBricks[2] = 0 then
  358.               puppetSound(3, "blue circle drop")
  359.               gFallSprite[2] = spriteNum
  360.               gFallingBricks[2] = 1
  361.             else
  362.               if gFallingBricks[3] = 0 then
  363.                 puppetSound(3, "blue circle drop")
  364.                 gFallSprite[3] = spriteNum
  365.                 gFallingBricks[3] = 1
  366.               else
  367.                 if gFallingBricks[4] = 0 then
  368.                   puppetSound(3, "blue circle drop")
  369.                   gFallSprite[4] = spriteNum
  370.                   gFallingBricks[4] = 1
  371.                 end if
  372.               end if
  373.             end if
  374.           end if
  375.           gScore = gScore + 300
  376.           member("Score01").text = "Score:" && string(gScore)
  377.           member("Score02").text = "Score:" && string(gScore)
  378.         end if
  379.       end if
  380.     end if
  381.   end if
  382. end
  383.  
  384. on donutAttack me
  385.   if gFallingBricks[1] = 1 then
  386.     if sprite(gFallSprite[1]).locV <= 450 then
  387.       gSlowDown = gSlowDown + 1
  388.       if gSlowDown >= 7 then
  389.         sprite(gFallSprite[1]).locV = sprite(gFallSprite[1]).locV + 1
  390.         gSlowDown = 0
  391.       end if
  392.       if sprite(gFallSprite[1]).intersects(2) then
  393.         sprite(2).member = "ship_frame 4"
  394.         sprite(gFallSprite[1]).locV = 500
  395.         sprite(gFallSprite[1]).visible = 0
  396.         if sprite(15).visible = 1 then
  397.           deathSequence()
  398.         end if
  399.         sprite(80).play()
  400.         gGoBall = 0
  401.         loseALife()
  402.       end if
  403.     else
  404.       sprite(gFallSprite[1]).visible = 0
  405.     end if
  406.   end if
  407.   if gFallingBricks[2] = 1 then
  408.     if sprite(gFallSprite[2]).locV <= 450 then
  409.       gSlowDown = gSlowDown + 1
  410.       if gSlowDown >= 7 then
  411.         sprite(gFallSprite[2]).locV = sprite(gFallSprite[2]).locV + 1
  412.         gSlowDown = 0
  413.       end if
  414.       if sprite(gFallSprite[2]).intersects(2) then
  415.         sprite(2).member = "ship_frame 4"
  416.         sprite(gFallSprite[2]).locV = 500
  417.         sprite(gFallSprite[2]).visible = 0
  418.         if sprite(15).visible = 1 then
  419.           deathSequence()
  420.         end if
  421.         sprite(80).play()
  422.         gGoBall = 0
  423.         loseALife()
  424.       end if
  425.     else
  426.       sprite(gFallSprite[2]).visible = 0
  427.     end if
  428.   end if
  429.   if gFallingBricks[3] = 1 then
  430.     if sprite(gFallSprite[3]).locV <= 450 then
  431.       gSlowDown = gSlowDown + 1
  432.       if gSlowDown >= 7 then
  433.         sprite(gFallSprite[3]).locV = sprite(gFallSprite[3]).locV + 1
  434.         gSlowDown = 0
  435.       end if
  436.       if sprite(gFallSprite[3]).intersects(2) then
  437.         sprite(2).member = "ship_frame 4"
  438.         sprite(gFallSprite[3]).locV = 500
  439.         sprite(gFallSprite[3]).visible = 0
  440.         if sprite(15).visible = 1 then
  441.           deathSequence()
  442.         end if
  443.         sprite(80).play()
  444.         gGoBall = 0
  445.         loseALife()
  446.       end if
  447.     else
  448.       sprite(gFallSprite[3]).visible = 0
  449.     end if
  450.   end if
  451.   if gFallingBricks[4] = 1 then
  452.     if sprite(gFallSprite[4]).locV <= 450 then
  453.       gSlowDown = gSlowDown + 1
  454.       if gSlowDown >= 7 then
  455.         sprite(gFallSprite[4]).locV = sprite(gFallSprite[4]).locV + 1
  456.         gSlowDown = 0
  457.       end if
  458.       if sprite(gFallSprite[4]).intersects(2) then
  459.         sprite(2).member = "ship_frame 4"
  460.         sprite(gFallSprite[4]).locV = 500
  461.         sprite(gFallSprite[4]).visible = 0
  462.         if sprite(15).visible = 1 then
  463.           deathSequence()
  464.         end if
  465.         sprite(80).play()
  466.         gGoBall = 0
  467.         loseALife()
  468.       end if
  469.     else
  470.       sprite(gFallSprite[4]).visible = 0
  471.     end if
  472.   end if
  473. end
  474.